// 引入vue路由
import VueRouter from "vue-router";
// 引入About组件
import About from "../pages/About";
// 引入Home组件
import Home from "../pages/Home";
// 引入Home嵌套子组件Message组件
import Message from "../pages/Message";
// 引入Home嵌套子组件News组件
import News from "../pages/News";
// 引入Home嵌套子组件News组件的嵌套子组件Detail组件
import Detail from "../pages/Detail";


// 创建并暴露路由
export default new VueRouter({
    routes:[
        // 一级路由
        {
            name:'about',
            path:'/about',
            component:About
        },
        {
            path:'/home',
            component:Home,
            children:[
                // 二级路由
                {
                    path:'message',
                    component:Message,
                    children:[
                        // 三级路由
                        {
                            name:'detail',
                            path:'detail',
                            component:Detail,
                            props:$route=>{
                                return {
                                    id:$route.query.id,
                                    title:$route.query.title,
                                }
                            }
                        }
                    ]
                },
                {
                    path:'news',
                    component:News
                }
            ]
        },
    ]
})